Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SEPA Requests to Encodable #1173

Merged
merged 6 commits into from
Jan 17, 2024
Merged

Update SEPA Requests to Encodable #1173

merged 6 commits into from
Jan 17, 2024

Conversation

jaxdesmarais
Copy link
Contributor

Summary of changes

  • Add encodable types for post bodies used in the SEPA Direct Debit flow:
    • Add SEPADebitAccountsRequest encodable type
    • Add SEPADebitRequest encodable type
  • The SEPA flow has been tested in the Demo app to ensure the dictionaries are still constructed as expected
  • Unit tests for these types are in SEPADirectDebitAPI_Tests

Checklist

  • [ ] Added a changelog entry

Authors

@jaxdesmarais jaxdesmarais requested a review from a team as a code owner January 12, 2024 21:30
import Foundation

/// The POST body for `v1/payment_methods/sepa_debit_accounts`
struct SEPADebitAccountsRequest: Encodable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ - do we want to create a /Models directory within each Sources/<PaymentMethod> directory? Specifically to house these new classes specific to encoding (and maybe eventually to house ones specific to decoding if we go that route).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that would be helpful. I was thinking that as I was adding this. Should we do that as a follow up PR for all of the models we've created so far? I think it changes the source paths for the package managers (at least Cocoapods). Also down to do that for SEPA in this PR and just a follow up for the other 2. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of having those be 1 PR! But your call

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool - agree we can 🏈 on it in this PR to establish a pattern in a single PR moving forward

case createMandateResult = "sepa_debit_account"
}

init(createMandateResult: CreateMandateResult) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - I would move the init to the bottom of this class.

Maybe these new Encodable structs is a good candidate for us to add to our style guide how we should organize these, MARKs, etc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had followed the pattern we established in BTApplePaymentTokensRequest where the nested struct is under the init. Though I do think having structs within structs could be making our preferred style more convoluted. Thoughts on removing the nesting?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh, looking back I think having all the struct definitions be near the property that uses it & pushing the init down is more readable vs having them intertwined. What do you think?

In terms of nested structs, I think they sometimes help readability to know when something is defined within the context of something else. For example with the ApplePaymentToken one, that name is pretty generic, but namespacing it the <Request>.ApplePaymentToken helps reduce name collisions.

Open to folks thoughts though!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh, looking back I think having all the struct definitions be near the property that uses it & pushing the init down is more readable vs having them intertwined. What do you think?

Yeah I am down if we feel like it makes things more readable! I pushed a commit here with the change: d479ab9

Also agree on style guiding whatever we decide (and finding a home for the style guide).

In terms of nested structs, I think they sometimes help readability to know when something is defined within the context of something else. For example with the ApplePaymentToken one, that name is pretty generic, but namespacing it the .ApplePaymentToken helps reduce name collisions.

That makes sense with naming collisions, I forgot about that aspect. Especially with something like card that could be a situation where a merchant has something similar by the same name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a backlog ticket for updating our style guide - DTBTSDK-3373

Comment on lines +23 to +26
let last4: String?
let merchantOrPartnerCustomerID: String?
let bankReferenceToken: String?
let mandateType: String?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit(entirely optional): maybe we can add short in-line docs to describe each property within these structs

Copy link
Contributor

@agedd agedd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! just left one small comment

@jaxdesmarais jaxdesmarais merged commit a16d4b5 into main Jan 17, 2024
7 checks passed
@jaxdesmarais jaxdesmarais deleted the sepa-encodable branch January 17, 2024 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants